<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"/>

    <title>找回登录密码</title>
    <link rel="stylesheet" href="../css/base.css"/>
    <style>
        /*头部css*/
        header{
            height: 1.3rem;
            padding-top: 0.4rem;
            line-height: 1.3rem;
            width: 100%;
            background-color: #fff;
            position:fixed;
            z-index:11;
            border-bottom: 1px solid #eeeeee;
        }
        header h3{
            text-align: center;
            color:#686868;
            font-size: 0.36rem;
        }
        header  i,header em{
            background: url("../img/b_left_03.png") no-repeat center;
            height: 0.9rem;
            width: 0.6rem;
            position: absolute;
            -webkit-background-size: 100%;
            background-size: 100%;
        }
        header  i{
            left: 2%;
            top: 38%;
        }
        .main{
            padding: 0.93rem 0.5rem 0 0.5rem;
        }
        .main h4   {
            width: 100%;
            height: 1.1rem;
            line-height: 1.1rem;
            font-size: 0.36rem;
            color:#333333;
        }
        .main form{
            position: relative;
            height: 0.68rem;
            border-bottom: 1px solid #eeeeee;
        }
        .main form span{
            font-size: 0.36rem;
            color:#333;
        }
        .main form input{
            font-size:0.36rem;
            margin-left:0.35rem;
        }
        .main form :before{
            content: "";
            position: absolute;
            width: 0.35rem;
            height: 0.28rem;
            background: url("../img/r_trig_03.png") no-repeat center;
            -webkit-background-size: 100%;
            background-size: 100%;
            left: 10%;
            top: 24%;
        }

        .main button{
            margin-top: 0.5rem;
            display: block;
            width: 100%;
            height: 0.88rem;
            -webkit-border-radius: 10px;
            -moz-border-radius: 10px;
            border-radius: 10px;
            background-color: #AA907F;
            color:#fff;
            font-size: 0.36rem;;
        }
        :-moz-placeholder { /* Mozilla Firefox 4 to 18 */
            color: #b8b8b8; opacity:1;
        }

        ::-moz-placeholder { /* Mozilla Firefox 19+ */
            color: #fff;opacity:1;
        }

        input:-ms-input-placeholder{
            color: #b8b8b8;opacity:1;
        }

        input::-webkit-input-placeholder{
            color: #b8b8b8;opacity:1;
        }
    </style>
</head>
<body>
<div class="layer">
    <header class="clearfix">
        <i onclick="back()" ></i>
        <h3>找回登录密码</h3>
    </header>
    <div class="main">
        <h4>请填写您要找回的密码的账号</h4>
        <form action="submit" class="phone">
            <span>+86</span><input type="text" placeholder="请输入手机号"/>
        </form>
        <button class="next">下一步</button>
    </div>
</div>
<script src="../js/x_rem.js"></script>
<script src="../js/jquery.js"></script>
<script>
   $(function(){
       function back(){
           history.go(-1);
       }
       //在这个页面要先判断用户输入的手机号格式是否正确 还要判断数据库里面是否存在此手机号注册的信息  （不判断存在应该也可以 留到下一页面）；

       function findPassword(){
           var phone=$(".phone input").val();
           //console.log(phone);
           if(isNotBlank(phone)){
               if(!checkTelNum(phone)){
                   alert("手机号格式不正确，请您查证后输入");
                   $(".phone input").val("");
                   return false;
               }else{//保存手机号
                 //localStorage.setItem("phone",JSON.stringify(phone));
                   var obj={};
                     obj.mobilePhone=phone;
                   //console.log(obj);
                   $.ajax({
                       xhrFields: {
                           withCredentials: true
                       },
                       type:"post",
                       data:obj,
                       dataType:"json",
                       url:baseUrl+"/student/doCode",
                       success:function(data){
                           console.log(data);
                           localStorage.setItem("find_code",JSON.stringify(data.code));
                          window.location.href='./change_login_password.html';
                       }
                   });
               }
           }else{
               alert("手机号不能为空");
               $(".phone input").val("");
               return false;
           }
       }

       function isNotBlank(data) {
           return (data == "" || typeof(data)  == "undefined"|| data == null ) ? false : true;
       }
       //验证手机号
       function checkTelNum(telNum){
           if(!/^1[0-9]{10}$/.test(telNum)){
               return false;
           }
           return true;
       }
        $(".next").click(function(){
            findPassword();

        })

   })
</script>
</body>
</html>